#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct car
{
    int d;
    int v;
    int a;
    int ti;

}che[MAXN];
int ans = 0;
int T;
int n,m,L,V;
int csy[MAXN],hx[MAXN];//cesuyi haxi
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while (T--)
    {
        cin >> n >> m >> L >> V;
        for (int i = 1 ; i <= n ; ++i)
        {
            cin >> che[i].d >> che[i].v >> che[i].a;
            //cout << che[i].d << " " << che[i].v << che[i].a << endl;
        }
        for (int i = 1 ; i <= m ; ++i) cin >> csy[i];
        for (int i = 1 ; i <= n ; ++i)
        {
            int zlc = che[i].d;
            int c = 1;
            int v = che[i].v;
            while(zlc < L)
            {
                zlc += che[i].v * 1;
                if (zlc >= csy[c])
                {
                    if (v > V)
                    {
                        ans ++;
                        hx[c]++;
                        break;
                    }

                }
                else c++;
            }
        }
    }
    int cnt;
    for (int i = 1 ; i <= n ; ++i) if(hx[i] == 0) cnt ++;
    cout << ans << " " << cnt << "\n";
    return 0;
}

